$(window).ready(function() {
	$("#btnMissionBriefing").click(missionBriefing);
	$("#btnPreferences").click(preferences);
	$("#btnIntelligence").click(intelligence);
	$("#btnDirections").click(directions);	
	
	locationUpdate(commandJSI.getMyLatitude(), commandJSI.getMyLongitude(), commandJSI.getTargetLatitude(), commandJSI.getTargetLongitude());
});


function missionBriefing() { commandJSI.missionBriefing();}
function preferences() { commandJSI.preferences();}
function intelligence() { commandJSI.intelligence();}
function myMaps() { commandJSI.myMaps();}
function targetMaps() { commandJSI.targetMaps();}
function directions() { commandJSI.directions();}



/**
 * 
 */
function locationUpdate(myLat, myLon, targetLat, targetLon) {
	$("#myLat").html(Math.round(myLat*1000)/1000);
	$("#myLon").html(Math.round(myLon*1000)/1000);
	$("#targetLat").html(Math.round(targetLat*1000)/1000);
	$("#targetLon").html(Math.round(targetLon*1000)/1000);
	
	updateMaps(myLat, myLon, targetLat, targetLon);
}

function updateMaps(myLat, myLon, targetLat, targetLon) {

	var myImageUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&center="
			+ myLat
			+ ','
			+ myLon
			+ "&zoom=14&size=300x400&markers=color:blue|label:S|"
			+ myLat + ',' + myLon;

	var targetImageUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&center="
		+ targetLat
		+ ','
		+ targetLon
		+ "&zoom=14&size=300x400&markers=color:blue|label:S|"
		+ targetLat + ',' + targetLon;

	$("#myMap").attr("src", myImageUrl);
	$("#targetMap").attr("src", targetImageUrl);

}
